<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>spe</title>
  </head>
  <body>
    <div id="app">
	<input type="file" id="img">
	预览：<img id="imgShow" src="" alt="">
	<button id="start">asdasd</button>
	</div>
    <script>
      var img = document.getElementById('img')
        , imgShow = document.getElementById('imgShow')
        , start = document.getElementById('start');
      start.addEventListener('click', startt);
      function startt() {
        let imgFile = new FileReader();
        console.log(img.files[0])
        imgFile.readAsDataURL(img.files[0]);
        imgFile.onload = function () {
          let imgData = this.result; //base64数据  this.result  需要保存到当前对象中去
          imgShow.setAttribute('src', imgData);
          conte.value = imgData;
          len.innerHTML += imgData.length;
        }
      }
    </script>
  </body>
</html>
